<template>
    <div class="">
        <el-container class="form-container" style="">
            <el-card class="box-card" shadow="never">
                <div slot="header" class="clearfix">
                    <span>基本信息</span>
                    <el-button type="primary" size="mini" style="float:right;padding: 6px 9px;margin-left:10px" @click="handlerResetPassword">重置密码</el-button>
                    <el-button type="primary" size="mini" style="float:right;padding: 6px 9px;" @click="handlerEdit">编辑</el-button>
                </div>
                <div >
                   <el-form  :rules="rules"  ref="form"   :model="form" size="small" label-width="120px">
                        <el-row>
                            <el-col :span="12">
                                <el-form-item  label="姓名">
                                    {{form.fdName}}
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item  label="编号">
                                    {{form.fdNo}}
                                </el-form-item>
                            </el-col>
                            
                            </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item  label="登录名">
                                    {{form.fdLoginName}}
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item  label="所属部门"  prop="fdParentName">
                                    {{form.fdParentName}}
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item  label="所属岗位"  prop="fdPostIds">
                                    {{form.fdPostNames}}
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item  label="生日"  prop="fdBirthDay">
                                    {{form.fdBirthDay|formatDate}}
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item  label="排序号"  prop="fdOrder">
                                    {{form.fdOrder}}
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item  label="微信号">
                                    {{form.fdWechatNo}}
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item  label="钉钉号">
                                    {{form.fdDingId}}
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item  label="手机号">
                                    {{form.fdMobileNo}}
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item  label="固定电话">
                                    {{form.fdTelPhone}}
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="是否有效" prop="fdIsAvaliable" >
                                    <el-switch v-model="form.fdIsAvaliable" :disabled="true"/>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item  label="创建时间" prop="fdCreateTime">
                                    {{form.fdCreateTime |formatDate}}
                                </el-form-item>
                            </el-col>
                        </el-row>
                   </el-form>
                </div>
            </el-card>
        </el-container>
        <el-dialog v-dialogDrag class="dialog" :title="title" center :visible.sync="visible" :close-on-click-modal="false" width="430px" :show-close="false">
            <reset-pwd :userId="form.fdId" :showCloseBtn="true" @close="handlerClose"/>
        </el-dialog>
    </div>
</template>
<script>
import dateUtils from '@/utils/dateUtils';
import formUtils from '@/utils/formUtils';
import ResetPwd from '@/components/page/sys/org/sys_org_person/comp/ResetPwd';

export default {
    name: "SysOrgPersonView",
    components: {
        ResetPwd
    },
    data() {
        return {
            form: {
                fdNo:'',
                fdId:'',
                fdName:'',
                fdLoginName:'',
                fdOrder:'',
                fdDingId:'',
                fdPassword:'',
                fdParentId:'',
                fdParentName:'',
                fdPostIds:'',
                fdPostNames:'',
                fdIsAvaliable:true,
                fdOrgName:'',
                fdWechatNo:'',
                fdMobileNo:'',
                fdTelPhone:'',
                fdBirthDay:'',
                fdCreateTime:'',
                fdOrgId:''
            },
            title:'重置密码',
            visible:false
        }
    },
    created() {
        this.initParam();
    },
    methods: {
        handlerEdit() {
            const params = {
                path: "/sys/org/sys_org_person/edit",
                query: {id:this.form.fdId}
            }
            this.$router.push(params);
        },
        initParam() {
            let fdId = this.$route.query.id;
            if(formUtils.isNotEmpty(fdId)){
                this.fullscreenLoading = true;
                this.$fetch('/api/sys/org/sys_org_person',{
                    id:fdId
                }).then((res) => {
                    formUtils.convertToForm(res.data,this.form);
                    this.fullscreenLoading = false;
                    this.form.fdBirthDay = dateUtils.formatDate(this.form.fdBirthDay);
                });
            }
        },
        handlerResetPassword(){
            this.visible = true;
        },
        handlerClose(){
            this.visible = false;
        }
    },
    filters:{
        formatDate(time) {
            return dateUtils.formatDate(time);
        }
    }
}
</script>
<style scoped >
@import "~@/assets/css/form.css";
</style>